# myapp/views.py
from django.views.generic import ListView, DetailView
from django.views.generic import FormView, CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy
from .models import PersonInfo
from django import forms
from django.views.generic.dates import MonthArchiveView, WeekArchiveView

class PersonInfoMonthArchiveView(MonthArchiveView):
    model = PersonInfo
    date_field = 'hireDate'
    template_name = 'myapp/personinfo_archive_month.html'

class PersonInfoWeekArchiveView(WeekArchiveView):
    model = PersonInfo
    date_field = 'hireDate'
    template_name = 'myapp/personinfo_archive_week.html'
class PersonInfoForm(forms.ModelForm):
    class Meta:
        model = PersonInfo
        fields = ['name', 'age', 'hireDate']

class PersonInfoCreateView(CreateView):
    model = PersonInfo
    form_class = PersonInfoForm
    template_name = 'myapp/personinfo_form.html'
    success_url = reverse_lazy('personinfo_list')

class PersonInfoUpdateView(UpdateView):
    model = PersonInfo
    form_class = PersonInfoForm
    template_name = 'myapp/personinfo_form.html'
    success_url = reverse_lazy('personinfo_list')

class PersonInfoDeleteView(DeleteView):
    model = PersonInfo
    template_name = 'myapp/personinfo_confirm_delete.html'
    success_url = reverse_lazy('personinfo_list')

class PersonInfoListView(ListView):
    model = PersonInfo
    template_name = 'myapp/personinfo_list.html'

class PersonInfoDetailView(DetailView):
    model = PersonInfo
    template_name = 'myapp/personinfo_detail.html'
